package cn.huiyunche.base.service.interfaces;

import cn.huiyunche.base.service.model.CWaybill;
import cn.huiyunche.base.service.model.CWaybillContacts;
import cn.huiyunche.base.service.model.SysAdminUser;
import cn.huiyunche.base.service.vo.*;
import cn.huiyunche.base.service.vo.detail.DeReDetailVo;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * 运单Service
 *
 * @author Administrator
 */
public interface CWaybillService {

    /**
     * Gets no grab list by page.
     *
     * @param page the page
     * @return no grab list by page
     * @Title: getNoGrabListByPage
     * @Description: 查询待接单运单列表
     * @return: Map<String Object>
     */
    Map<String, Object> getNoGrabListByPage(PageVo page, Boolean isVeneer);

    /**
     * Gets already grab list by page.
     *
     * @param page the page
     * @return already grab list by page
     * @Title: getAlreadyGrabListByPage
     * @Description: 查询已接单运单列表 === 执行中
     * @return: Map<String Object>
     */
    Map<String, Object> getAlreadyGrabListByPage(PageVo page, Boolean isVeneer);

    /**
     * Gets done list by page.
     *
     * @param page the page
     * @return Map<String Object>
     * @Title: getDoneListByPage
     * @Description: 查询已完成运单列表
     */
    Map<String, Object> getDoneListByPage(PageVo page, Boolean isVeneer);

    /**
     * Gets by id.
     *
     * @param id 运单id
     * @return by id
     * @Title: getById
     * @Description: 根据id查询订单
     * @return: WaybillNewVo
     */
    WaybillNewVo getById(Long id);

    /**
     * Grab one long.
     *
     * @param id       运单id
     * @param driverId 实际承运人（司机）id
     * @return long long
     * @throws Exception the exception
     * @Title: grabOne 接单
     * @Description: 更新运单的承运人
     * @return: Long 运单id
     */
    Long grabOne(Long id, Long driverId) throws Exception;

    /**
     * Confirm send long.
     *
     * @param id        运单id
     * @param attachs   照片信息
     * @param adminUser the admin user
     * @return long long
     * @Title: confirmSend
     * @Description: 上传提车照片 待提车
     * @return: Long
     */
    Long confirmSend(Long id, String attachs, SysAdminUser adminUser) throws Exception;

    /**
     * Confirm dliver long.
     *
     * @param id        订单id
     * @param attachs   照片信息
     * @param adminUser the admin user
     * @return long long
     * @Title: confirmDliver
     * @Description: 确定交车 上传交车照片 已交车
     * @return: Long
     */
    Long confirmDliver(Long id, String attachs, SysAdminUser adminUser);

    /**
     * Update complete order int.
     *
     * @param id 订单id
     * @return int int
     * @Title: updateCompleteOrder
     * @Description: 更新订单为已完成
     * @return: int
     */
    int updateCompleteOrder(Long id);

    /**
     * Update status long.
     *
     * @param id      the id
     * @param status  the status
     * @param sStatus the s status
     * @param user    the user
     * @return long long
     * @Title: updateStatus
     * @Description: 更新运单状态
     * @return: Long
     */
    Long updateStatus(Long id, int status, int sStatus, UserVo user);

    /**
     * Update status for order long.
     *
     * @param orderId 订单id
     * @param status  状态
     * @return the long
     * @Title: updateStatusForOrder
     * @Description: 订单状态改变时同步更新运单状态
     * @return: Long 运单id
     */
    Long updateStatusForOrder(Long orderId, int status);

    /**
     * Gets undrawn list by page.
     *
     * @param page the page
     * @return undrawn list by page
     * @Title: getUndrawnListByPage
     * @Description: 查询未提车列表
     * @return: Result<Map StringObject>>
     */
    Map<String, Object> getUndrawnListByPage(PageVo page) throws Exception;

    /**
     * Gets no delivery list by page.
     *
     * @param page the page
     * @return no delivery list by page
     * @Title: getNoDeliveryListByPage
     * @Description: 查询待交车列表
     * @return: Map<String Object>
     */
    Map<String, Object> getNoDeliveryListByPage(PageVo page) throws Exception;

    /**
     * Select by userid and status list.
     *
     * @param userId     用户id
     * @param statusList 多个状态
     * @return list list
     * @Title: selectByUseridAndStatus
     * @Description: 根据用户 ，状态 查询数据
     * @return: Integer
     */
    List<CWaybill> selectByUseridAndStatus(Long userId, List<Integer> statusList);

    /**
     * Gets way bill by id.
     *
     * @param id 运单id
     * @return way bill by id
     * @Title: getById
     * @Description: 根据id查询运单
     * @return: WaybillNewVo
     */
    CWaybill getWayBillById(Long id);

    /**
     * Gets all list by page.
     *
     * @param page the page
     * @return all list by page
     * @Title: getAllListByPage
     * @Description: 查询全部订单
     * @return: Map<String Object>
     */
    Map<String, Object> getAllListByPage(PageVo page) throws Exception;

    /**
     * Gets by order id.
     *
     * @param orderId 订单id
     * @return by order id
     * @Title: getByOrderId
     * @Description: 根据订单id获取运单
     * @return: CWaybill
     */
    CWaybill getByOrderId(Long orderId);

    /**
     * 创建运单
     *
     * @param cWaybillDetailsVo the c waybill details vo
     * @param adminUser         the admin user
     * @return result result
     */
    Result<String> create(CWaybillDetailsVo cWaybillDetailsVo, SysAdminUser adminUser);

    /**
     * 查询运单参考价
     *
     * @param cWaybillDetailsVo the c waybill details vo
     * @return string string
     */
    String selectPrice(CWaybillDetailsVo cWaybillDetailsVo) throws Exception;

    /**
     * 根据服务订单 查询所有运单
     *
     * @param serviceOrderId the service order id
     * @return list list
     */
    List<CWaybillByIdVo> selectBySid(Long serviceOrderId);

    /**
     * 查询运单列表
     *
     * @param page      the page
     * @param waybillVo the waybill vo
     * @return map map
     * @throws Exception the exception
     */
    Map<String, Object> list(PageVo page, WaybillNewsVo waybillVo) throws Exception;

    /**
     * 根据运单ID 查询运单详情
     *
     * @param id the id
     * @return c waybill by id vo
     */
    CWaybillByIdVo selectById(Long id);

    /**
     * 查询交接单信息
     *
     * @param vo the vo
     * @return waybill contacts vo
     * @throws Exception the exception
     */
    WaybillContactsVo selectWaybillContact(WaybillContactsVo vo) throws Exception;

    /**
     * 提车审核
     *
     * @param waybillId the waybill id
     * @return long long
     * @throws Exception the exception
     */
    long liftAudit(Long waybillId) throws Exception;

    /**
     * 交车审核
     *
     * @param waybillId the waybill id
     * @return long long
     * @throws Exception the exception
     */
    long dealAudit(Long waybillId) throws Exception;

    /**
     * Gets exinfo.
     *
     * @param caybillId     运单id
     * @param dispatchTimes 调度次数
     * @return the exinfo
     * @Title: getExinfo
     * @Description: 查询运单的提车信息
     * @return: DeReDetailVo
     */
    List<DeReDetailVo> getExinfo(long caybillId, int dispatchTimes);

    /**
     * Gets deinfo.
     *
     * @param caybillId 运单id
     * @return the deinfo
     * @Title: getDeinfo
     * @Description: 查询运单的交车信息
     * @return: DeReDetailVo
     */
    List<DeReDetailVo> getDeinfo(long caybillId);

    /**
     * Driver start long.
     *
     * @param id the id
     * @return long long
     * @throws Exception
     * @Description 确认发车按钮 运单状态变为待交车WAITSTART
     */
    Long driverStart(Long id);

    /**
     * Proposed price big decimal.
     *
     * @param depaCode        起始地编码
     * @param depaAddr        起始地详细地址
     * @param destCode        目的地编码
     * @param destAddr        目的地详细地址
     * @param adate           起运时间
     * @param atime           起运时间上下午（0~12点，13~24点）
     * @param serviceOrderIds 服务订单主键
     * @return the big decimal
     * @Title: proposedPrice
     * @Description: 运单参考价格
     * @return: BigDecimal
     */
    BigDecimal proposedPrice(String depaCode, String depaAddr, String destCode, String destAddr, Date adate, int atime, List<Long> serviceOrderIds);

    /**
     * 提车安排通知
     *
     * @param serviceOrderIdList the service order id list
     * @param userId             the user id
     */
    void sendExtractMessage(List<Long> serviceOrderIdList, Long userId);

    /**
     * 提车安排通知 物流企业安排司机提车
     *
     * @param serviceOrderIdList the service order id list
     * @param contacts           the contacts
     */
    void sendExtractMessage2(List<Long> serviceOrderIdList, CWaybillContacts contacts);

    /**
     * 交车通知
     *
     * @param serviceOrderIdList the service order id list
     */
    void sendDeliveryMessage(List<Long> serviceOrderIdList);

    /**
     * 修改运单支付状态为：已支付
     *
     * @param waybillId the waybill id
     * @return the int
     */
    int updatePayStatus(Long waybillId);

    /**
     * 同城 创建运单
     *
     * @param serviceOrderId the service order id
     * @param bidderId       the bidder id
     * @param waybillType    the waybill type
     * @param sysAdminUser   the sys admin user
     * @return result result
     */
    Result<String> createVeneer(Long serviceOrderId, Long bidderId, Integer waybillType, SysAdminUser sysAdminUser);

    /**
     * Save c waybill with user to redis string.
     * 保存派单信息到redis中
     *
     * @param cWaybillId the c waygbill id
     * @param userId     the user id
     * @return the string
     */
    String saveCWaybillWithUserToRedis(Long cWaybillId, Long userId);

    /**
     * Remove c waybill with user from redis boolean.
     * 从redis中删除用户和运单信息
     *
     * @param cWaybillId the c waybill id
     * @param userId     the user id
     * @return the boolean
     */
//    Boolean removeCWaybillWithUserFromRedis(Long cWaybillId, Long userId);

    /**
     * Get c waybill by user from redis long [ ].
     * 通个用户主键返回运单主键，从redis中
     *
     * @param userId the user id
     * @return the long [ ]
     */
    List<Long> getCWaybillByUserFromRedis(Long userId);

    /**
     * Gets user by c waybill from redis.
     * 根据运单主键返回用户主键，从redis中
     *
     * @param cWaybillId the c waybill id
     * @return the user by c waybill from redis
     */
    Long getUserByCWaybillFromRedis(Long cWaybillId);

    /**
     * Is exist in redis boolean.
     * 判断运单有没有指派给用户
     *
     * @param cWaybillId the c waybill id
     * @param userId     the user id
     * @param isRemove   the is remove
     * @return the boolean
     */
    Boolean isExistInRedis(Long cWaybillId, Long userId, Boolean isRemove);

    /**
     * Gets all c waybill with user from redis.
     * 查询redis中所有被指派的运单
     *
     * @return the all c waybill with user from redis
     */
    List<String> getAllCWaybillWithUserFromRedis();

}